package com.example.session.controller;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/SessionController")
public class SessionController {

    @Value("${server.port}")
    Integer port;
    @RequestMapping("/hello")
    @ResponseBody
    public String hello(){
        return "hello";
    }

    @RequestMapping("/set")
    @ResponseBody
    public String set(HttpSession session){
        session.setAttribute("javaboy","javaboy123");
        return String.valueOf(port);
    }
    @RequestMapping("/get")
    @ResponseBody
    public String get(HttpSession session){
        String javaboy = (String)session.getAttribute("javaboy");
        return javaboy + ":" + port;
    }


}
